package org.radar.vm;

import org.radar.os.OSUtils;
import org.radar.os.PlatformEnum;

/**
 * VmTool工具类
 *
 * @author zhangcs
 * @since 1.0
 */
public class VmToolUtils {

    /**
     * JNI依赖名称
     */
    public static final String JNI_LIBRARY_NAME = "RadarJniLibrary";

    /**
     * JNI依赖文件名称
     */
    private static final String LIB_FILE_NAME;

    static {
        PlatformEnum platform = OSUtils.getPlatform();
        switch (platform) {
            case LINUX:
                LIB_FILE_NAME = JNI_LIBRARY_NAME + "-x64.so";
                break;
            case MACOS:
                LIB_FILE_NAME = JNI_LIBRARY_NAME + "-x64.dylib";
                break;
            default:
                LIB_FILE_NAME = JNI_LIBRARY_NAME + "-x64.dll";
        }
    }

    /**
     * 获取依赖文件名称
     *
     * @return 返回文件名称（文件名+后缀，例如：RadarJniLibrary-x64.so）
     */
    public static String detectLibName() {
        return LIB_FILE_NAME;
    }

}
